package com.atguigu.java;
import org.junit.Test;
/**
 * ClassName: StringTest2
 * Description:
 * Date: 2021/3/9 21:15
 * Company: TravelSky
 *
 * @author YangXin
 */
public class StringTest2 {

    @Test
    public void test1(){

        String s1 = "a" + "b" + "c";//编译之后,等同于"abc"
        String s2 = "abc";//"abc"一定是放在字符串常量池总,将此地址赋给s2

        System.out.println(s1 == s2);
        System.out.println(s1.equals(s2));


    }
    @Test
    public void test2(){

        String s1 = "javaEE";
        String s2 = "hadoop";

        String s3 = "javaEEhadoop";
        String s4 = "javaEE" + "hadoop";
        String s5 =  s1 +"hadoop";
        String s6 = "javaEE" + s2;
        String s7 = s1 + s2;

        System.out.println(s3 == s4);
        System.out.println(s3 == s5);
        System.out.println(s3 == s6);
        System.out.println(s3 == s7);
        System.out.println(s5 == s6);
        System.out.println(s5 == s7);
        System.out.println(s6 == s7);

        String s8 = s6.intern();
        System.out.println(s3 == s8);

    }


}
